CloudKit

RSS for tag

Store structured app and user data in iCloud containers that can be shared by all users of your app using CloudKit.

CloudKit Documentation

Posts under CloudKit tag

251 Posts
Sort by:
Post not yet marked as solved
1 Replies
47 Views
I'm trying to integrate the option to the player to save their data in the cloud, I integrate the CloudKit, change some stuff to make it work and build in Xcode to my phone. But when I try to integrate the CloudSave, 50 unnasigned symbols jump,like this one: Undefined symbol: _CKContainer_Default I managed to fix them by updating the recommended settings for Xcode. But then 4 more errors appear: Sandbox: il2cpp(12538) deny(1) file-read-data /Users/Username/Test Apple Kit 2022/Build/Il2CppOutputProject/IL2CPP/build/deploy_arm64/il2cpp So, don't let me build and I've looked everywhere but no one seems to had this same error
Posted Last updated
.
Post not yet marked as solved
2 Replies
108 Views
SwiftData includes support for CloudKit sync. However, I don't see any way to add conflict resolution behavior. For example, if different devices set different values for a field, or if a relationship is orphaned because of a deletion on another device, the application has to handle this somehow. In Core Data (which SwiftData wraps), you can handle this with the conflict resolution system (docs) and classes like NSMergePolicy. Is any of this accessible in SwiftData? If not, how do you deal with conflicts when syncing a SwiftData model with the cloud?
Posted Last updated
.
Post not yet marked as solved
1 Replies
26 Views
Hi, I'm about to adopt .externalStorage but I will also use CloudKit in the near future. I did not find any reference that list of requirements for SwiftData models to be used with CloudKit, only for Core Data models. It seems those Core Data requirements (like no-unique) apply to SwiftData as well. However I did not find any info on this: Can @Attribute(.externalStorage) be used when I want to sync my model with CloudKit?
Posted Last updated
.
Post not yet marked as solved
1 Replies
111 Views
When I go to Settings and tap on the account, choose iCloud>manage account storage and try to delete the storage associated with an app id developer mode, it doesn't give me the option to delete the data. I have tried using the CloudKit Console to delete the container data, but the entry for the app is still there. How do I delete it?
Posted Last updated
.
Post not yet marked as solved
1 Replies
87 Views
Hello, Prior to iOS 17, it was possible to request user discoverability by calling ‚requestApplicationPermission‘. But now it is deprecated. How is the intended way to do this now? How this is for example handled in the Music App? I think this should be a similar approach. Currently the only option for me seems to save the Email-Address (and maybe phone number) in the CloudKit public database, that other user can discover by this. But that the problem exists, that we need to fetch for changes at phone numbers and mail addresses that are linked to the iCloud account (because user might change anything). Is there a more elegant solution, than just checking the current email addresses and phone numbers at each start of the application (if that is even possible)? For example the Music App has that Switch "Find my by Apple-ID" but I don't know how this is handled in the background. Thanks!
Posted
by wastene.
Last updated
.
Post not yet marked as solved
2 Replies
162 Views
Has anyone successfully persisted Color, particularly in SwiftData? So far my attempts have failed: Making Color conform to Codable results in a run time error (from memory something about ColorBox). Color.Resolved already conforms Codable but this results in "SwiftData/ModelCoders.swift:124: Fatal error: Composite Coder only supports Keyed Container" None of the other color types conform to Codable (CGColor, NSColor and UIColor) so does the swift language really not have a persistable color type?
Posted
by Uasmel.
Last updated
.
Post not yet marked as solved
1 Replies
90 Views
Recently, I have made quite extensive changes to my schema and need to migrate my CoreData + CloudKit model to a new version. The changes require me to use a custom NSEntityMigrationPolicy because I have a rather complex mapping between some old entities and new entities. I have added a new model version. Deleted some entities, and added some entities. I have defined the NSEntityMigrationPolicy with createDestinationInstances(forSource:in:manager:) and createRelationships(forDestination:in:manager:). I have created a new Core Data Mapping Model. This was probably unnecessary. Within the Core Data Mapping Model, I have specified Custom Policy for all entities. In my container setup, I added two options, as below: storeDescription.setOption(false as NSNumber, forKey: NSMigratePersistentStoresAutomaticallyOption) storeDescription.setOption(false as NSNumber, forKey: NSInferMappingModelAutomaticallyOption) I mostly followed a "Core Data Heavyweight Migration" guide. I'm unable to share the link, but it can be quite easily found on the web. (It's not for CloudKit specifically.) When I run my app, I am getting the most basic of errors, which is: The managed object model version used to open the persistent store is incompatible with the one that was used to create the persistent store. So I guess that migration wasn't even attempted, which makes sense because I set NSMigratePersistentStoresAutomaticallyOption to false. I tried to go beyond what I could find on the web and attempted to manually initialize migration: let sourceModel = container.persistentStoreCoordinator.managedObjectModel guard let modelURL = Bundle.main.url(forResource: "MyModelName", withExtension: "xcdatamodeld") else { fatalError("Unable to locate model file.") } guard let destinationModel = NSManagedObjectModel(contentsOf: modelURL) else { fatalError("Unable to load destination model.") } let migrationManager = NSMigrationManager(sourceModel: sourceModel, destinationModel: destinationModel) let mappingModel = NSMappingModel(from: [Bundle.main], forSourceModel: sourceModel, destinationModel: destinationModel)! migrationManager.currentEntityMapping.entityMigrationPolicyClassName = "MyMigrationPolicyClassName" I am then stuck at the migrateStore(from:type:mapping:to:type:) method. It seems to target only local storage, not CloudKit. Otherwise, what do I provide for URLs and types? Any guidance for custom logic CoreData with CloudKit migration would be greatly appreciated.
Posted Last updated
.
Post marked as solved
2 Replies
103 Views
I have been working on an ios application which I decided to use the new SwiftData architecture, and I now have realized that SwiftData does not support public or shared databases using SwiftData. I am a new and upcoming Swift developer, who has been self learning the Apple Swift technology. I just learned in this forum that Swift Data does not support Public and Shared Data and I also understand that no plans that have been announced to addressed this feature in the IOS 18 release time frame. The use case for my application is to implement a social type application, something like applications including X, facebook, etc. These type of applications appear to use Public, Shared and Private data in various existing Apple application. I would like to complete an application using Swift using ICloud, but I must assume that these current social applications are using other technologies. I am assuming you can do this in Core Data, but my understanding is Apple is asking that we use Swift Data to replace core data. I also am assuming that Swift data is built on core data technology layers. So ... to me it seems hopeful, somehow, to accomplish this using IOS 17 and follow the recommend Swift Data Path. What are my options for completing these data objectives in IOS? I hope I am addressing these questions in the proper and best forum? Much thanks for any suggestions.
Posted
by bxw0405.
Last updated
.
Post not yet marked as solved
1 Replies
533 Views
I’m using NSPersistentCloudKitContainer and I’m utilising the public database and also the user’s private database. For example I have an entity called Category which has a many-to-many relationship to an entity called NewsArticle. So the NewsArticles exist in the public database for the user to browse, but he can add them to a category which will live in his private database. So that’s my question, is it possible for an entity which exists a in the private database to have a relationship to another entity in a public database?
Posted Last updated
.
Post not yet marked as solved
1 Replies
67 Views
I am following this document from Apple to implement sharing with CloudKit. In it, Apple says NSPersistentCloudKitContainer uses CloudKit zone sharing to share objects. Each share has its own record zone on the CloudKit server. CloudKit has a limit on how many record zones a database can have. What is the record zone limit for a private CloudKit database? I can find information about record and participant limits but not on record zone limits.
Posted Last updated
.
Post not yet marked as solved
0 Replies
133 Views
How can we identify whether the remote change notification is triggered because some data was changed on a different device and it is downloaded from CloudKit, or it is triggered from the current device because new entity was saved into database. Because this notification is posted when both remote data is downloaded or local data is created. It would be great if there is a way to understand the origin of the notification.
Posted
by emrepun.
Last updated
.
Post not yet marked as solved
0 Replies
127 Views
CoreData: Zone metadata is missing it's encoded share data but is marked for a mutation: <CKRecordZoneID: 0x600003f044e0; zoneName=com.apple.coredata.cloudkit.share.30BE5FAE-3FE0-4142-90C4-E78FFA90B2A2, ownerName=defaultOwner> - <decode: bad range for [%@] got [offs:312 len:1242 within:0]>
Posted
by viraf.
Last updated
.
Post not yet marked as solved
3 Replies
1.3k Views
I have a CoreData model, in a Swift Package with tests. I can successfully run the tests, when I load the model using NSPersistentContainer, however attempting this with NSPersistentCloudKitContainer always fails in the call to loadPersistentStores(completionHandler block: @escaping (NSPersistentStoreDescription, Error?) -> Void) The error is : [CK] BUG IN CLIENT OF CLOUDKIT: Not entitled to listen to push notifications. Please add the 'aps-connection-initiate' entitlement. This issue is described on StackOverflow however, the accepted solution does not appear to work in my case. I have tried adding the aps-connection-initiate key to my App Info.plist, the Test Info.plist and the SPM bundle. No change. (NB. adding this to the entitlements file just breaks auto signing). I have enabled App entitlements for App Groups, Remote Notifications background mode, Push Notifications and iCloud CloudKit with a store identifier. I have checked my model. All relationships have inverses. No unique constraints, etc. etc. I am sharing a Bundle ID with a previous version of the App, that also uses CoreData+CloudKit, each version has it's own Model and container identifier, each container identifier is available in the provisioning profile. The new version of the model has two NSPersistentStoreDescriptions, one is configured for CloudKit, the other is a local cache. I am completely stuck, suggestions would be very welcome.
Posted
by jeremy51.
Last updated
.
Post not yet marked as solved
0 Replies
125 Views
I deployed Xcode to iPhone, emulator and iPhone, and iCloud data is synchronized. But I am using testlight for distribution, so I cannot synchronize. I did not respond in iCloud Kit Database developer mode, and now I have changed to production mode, but there is no response, so I cannot synchronize. That's why.
Posted Last updated
.
Post not yet marked as solved
0 Replies
123 Views
A few months back, I launched an app that operated solely on a local level. Recently, I've begun the process of integrating it with CloudKit, and so far, the model integration has been successful. I've utilized SwiftData for this task, making it relatively straightforward to adjust the models, as shown below: ` @Relationship(deleteRule: .cascade, inverse: \ItemForCategory.category) var itemForCategory : [ItemForCategory]? = [ItemForCategory]() ` In my initial version of the code, the widget functioned perfectly. However, I've encountered an error recently stating Missing return in instance method expected to return 'ItemForCategory?'. @MainActor private func getLastItem () -> ItemForCategory? { guard let modelContainer = try? ModelContainer(for: Category.self) else { return nil } let descriptor = FetchDescriptor<Category>() let appCategories = try? modelContainer.mainContext.fetch(descriptor) let lastItem = appCategories?.compactMap { $0.itemForCategory }.last return lastItem } The error surfaces at the return line of code. I'm hopeful that someone can assist me in resolving this issue. Thank you very much.
Posted Last updated
.
Post not yet marked as solved
0 Replies
135 Views
I'm using CoreData+CloudKit. It works fine in development, so I deployed to production. But I cannot see the data in CloudKit DataBase in a testflight version. I don't know where I missed. Can I just run in Release mode to check it works?
Posted
by WWWang.
Last updated
.
Post not yet marked as solved
1 Replies
126 Views
Hello. I recently released a new version (2.6) of my CloudKit syncing CoreData based app. The new version uses v18 of my data model. V18 is exactly like v17, except for a new optional string field in one of the entities. I diffed the two model versions to be extra sure. During my test I did not encounter any crash, and I also tested automatic migration, installing 2.55 and building 2.6 on top of it. No troubles. However my crash logger reports a number of crashes among my users. It's not a huge numbers (10 users over about 900 or more) but I am surprised it crashes at all. The crash happens when I call NSPersistentCloudKitContainer.loadPersistentStores, I get this error in the completion block: The model used to open the store is incompatible with the one used to create the store" I always assumed these slight changes (new field added to an existing model) did not require a manual migration. Any suggestions?
Posted
by nuutsss.
Last updated
.